<template>
  <div
    class="f-tag-list"
    :style="{ left: $store.state.asideWidth }"
  >
    <el-tabs
      v-model="activeTab"
      type="card"
      class="demo-tabs"
      style="min-width: 100px"
      @tab-remove="removeTab"
      @tab-change="changeTab"
    >
      <el-tab-pane
        v-for="item in tabList"
        :key="item.path"
        :label="item.title"
        :name="item.path"
        :closable="item.path != '/'"
      ></el-tab-pane>
    </el-tabs>

    <span class="tag-btn">
      <el-dropdown @command="handleClose">
        <span class="el-dropdown-link">
          <el-icon>
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item command="clearOther">关闭其他</el-dropdown-item>
            <el-dropdown-item command="clearAll">全部关闭</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </span>
  </div>
  <div style="height: 44px"></div>
</template>

<script setup>
import { useTabList } from "~/composables/useTabList.js";

const { activeTab, tabList, changeTab, removeTab, handleClose } = useTabList();
</script>

<style lang="less" scoped>
.f-tag-list {
  @apply fixed bg-gray-100 flex items-center px-2;
  top: 64px;
  right: 0;
  height: 44px;
  z-index: 100;
}

.tag-btn {
  @apply bg-white rounded ml-auto flex items-center justify-center px-2;
  height: 40px;
}

:deep(.el-tabs__header) {
  margin-bottom: 0 !important;
  border: 0 !important;
  .el-tabs__nav {
    border: 0 !important;
  }
}

:deep(.el-tabs__item) {
  border: 0 !important;
  height: 40px;
  line-height: 40px;
  @apply bg-white mx-1 rounded;
}

.is-disabled {
  cursor: not-allowed !important;
  @apply text-gray-300 !important;
}

.el-dropdown-link:focus {
  outline: none;
}
</style>
